const saveData = {
    session: {
        getItem(name: string): any{
            if(sessionStorage.getItem(name))
                return JSON.parse(<string>sessionStorage.getItem(name))
            else
                return false
        },
        setItem(name, value){
            sessionStorage.setItem(name, JSON.stringify(value))
        },
        removeItem(name=''){
            if(name)
                sessionStorage.removeItem(name)
            else
                sessionStorage.clear()
        }
    },
    storage: {
        getItem(name: string){
            return JSON.parse(<string>localStorage.getItem(name))
        },
        setItem(name: string, value: any){
            localStorage.setItem(name, JSON.stringify(value))
        },
        removeItem(name=''){
            if(name)
                localStorage.removeItem(name)
            else
                localStorage.clear()
        }
    }
}

export default saveData
